﻿using System;

#if WINDOWS_PHONE
namespace Fibre.WP7.Threading
#else
#if SILVERLIGHT
namespace Fibre.Silverlight.Threading
#else
namespace Fibre.Threading
#endif
#endif
{
    /// <summary>
    /// Work context, allows subscription to completed callback
    /// </summary>
    public interface IWorkContext : IWorkContextBase
    {
        /// <summary>
        /// Subscribes to callback when this work completes.
        /// You can perform additional work by calling DoWork on the completion context.
        /// Example: WhenComplete(c => c.DoWork(() => { DoSomeAdditionalWork(); }))
        /// </summary>
        /// <param name="completionContext">The completion context.</param>
        /// <returns></returns>
        IWorkContext WhenComplete(Action<IWorkCompleteContext> completionContext);
    }

    /// <summary>
    /// Work context, allows subscription to completed callback and addition of more work.
    /// </summary>
    /// <typeparam name="T">The type of the result returned in completed callback</typeparam>
    public interface IWorkContext<T> : IWorkContextBase
    {
        /// <summary>
        /// Subscribes to callback when this work completes.
        /// You can perform additional work by calling DoWork on the completion context.
        /// Example: WhenComplete(c => c.DoWork(() => { DoSomethingWithResult(c.Result); }))
        /// </summary>
        /// <param name="completionContext">The completion context.</param>
        /// <returns></returns>
        IWorkContext<T> WhenComplete(Action<IWorkCompleteContext<T>> completionContext);
    }
}
